

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/insert1.png">
  <link rel="icon" href="/img/insert1.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  
    <meta name="description" content="无聊的人生只剩下无尽的空虚。">
  
  <meta name="author" content="Mike Taylor">
  <meta name="keywords" content="我的博客">
  
  <title>CSS属性-动画 - Mike Taylor</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.4.0/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"gitee.com","root":"/","version":"1.8.8","typing":{"enable":true,"typeSpeed":30,"cursorChar":"|","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"onlypost":false},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null}}};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>Mike Taylor's</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                主页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                日志
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                目录
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                个人
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="CSS属性-动画">
              
            </span>

            
              <div class="mt-3">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-author" aria-hidden="true"></i>
      Mike Taylor
    </span>
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-05-05 23:25" pubdate>
        2021年5月5日 晚上
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      4.2k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      67
       分钟
    </span>
  

  
  
    
      <!-- 不蒜子统计文章PV -->
      <span id="busuanzi_container_page_pv" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="busuanzi_value_page_pv"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">CSS属性-动画</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：2021年5月7日 晚上
                
              </p>
            
            <div class="markdown-body">
              <h1 id="第八章-CSS3属性-动画"><a href="#第八章-CSS3属性-动画" class="headerlink" title="第八章 CSS3属性-动画"></a>第八章 CSS3属性-动画</h1><p><strong>课程提要</strong></p>
<ul>
<li>盒子的变形</li>
<li>CSS3过渡</li>
<li>CSS3动画</li>
</ul>
<h2 id="8-1盒子的变形"><a href="#8-1盒子的变形" class="headerlink" title="8.1盒子的变形"></a>8.1盒子的变形</h2><p>transform属性向元素应用2D或者3D转换。该属性允许我们对元素进行旋转、缩放、移动或者倾斜。</p>
<h3 id="8-1-1-CSS3-2D变形"><a href="#8-1-1-CSS3-2D变形" class="headerlink" title="8.1.1 CSS3 2D变形"></a>8.1.1 CSS3 2D变形</h3><h4 id="2D-Transform方法"><a href="#2D-Transform方法" class="headerlink" title="2D Transform方法"></a>2D Transform方法</h4><table>
<thead>
<tr>
<th>函数</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>matrix(n,n,n,n,n,n)</td>
<td>定义2D转换，使用六个值得矩阵。</td>
</tr>
<tr>
<td>translate(x,y)</td>
<td>定义2D转换，沿着X和Y轴移动元素。（位移）</td>
</tr>
<tr>
<td>translateX(n)</td>
<td>定义2D转换，沿着X轴移动元素。</td>
</tr>
<tr>
<td>translateY(n)</td>
<td>定义2D转换，沿着Y轴移动元素。</td>
</tr>
<tr>
<td>scale(x,y)</td>
<td>定义2D缩放转换，改变元素的宽度和高度。（缩放）</td>
</tr>
<tr>
<td>scaleX(n)</td>
<td>定义2D缩放转换，改变元素的宽度。</td>
</tr>
<tr>
<td>scaleY(n)</td>
<td>定义2D缩放转换，改变元素的高度。</td>
</tr>
<tr>
<td>rotate(angle)</td>
<td>定义2D旋转，在参数中规定角度。(-360deg ~ 360deg)       （旋转）</td>
</tr>
<tr>
<td>skew(x-angle,y-angle)</td>
<td>定义2D倾斜转换，沿着X和Y轴。   （变形）</td>
</tr>
<tr>
<td>skewX(angle)</td>
<td>定义2D倾斜转换，沿着X轴。</td>
</tr>
<tr>
<td>skewY(angle)</td>
<td>定义2D倾斜转换，沿着Y轴。</td>
</tr>
</tbody></table>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        *&#123;<br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;</span><br><span class="css">            <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;</span><br>        &#125;<br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: red;</span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: translate(100px,200px);!*兼容谷歌和苹果*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: translate(100px,200px);!*兼容火狐*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: translate(100px,200px);!*兼容IE*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: translate(100px,200px);!*兼容opera浏览器*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: translate(100px,200px);!*兼容W3C浏览器*!*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*可以为负值*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: translate(-100px,200px);!*兼容谷歌和苹果*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: translate(-100px,200px);!*兼容火狐*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: translate(-100px,200px);!*兼容IE*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: translate(-100px,200px);!*兼容opera浏览器*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: translate(-100px,200px);!*兼容W3C浏览器*!*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*!*只带一个参数，该参数代表的是X方向位移为位移值，y方向位移值为0*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: translate(100px);!*兼容谷歌和苹果*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: translate(100px);!*兼容火狐*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: translate(100px);!*兼容IE*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: translate(100px);!*兼容opera浏览器*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: translate(100px);!*兼容W3C浏览器*!*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: translateX(100px);!*兼容谷歌和苹果*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: translateX(100px);!*兼容火狐*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: translateX(100px);!*兼容IE*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: translateX(100px);!*兼容opera浏览器*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: translateX(100px);!*兼容W3C浏览器*!*/</span></span><br><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateY</span>(<span class="hljs-number">100px</span>);<span class="hljs-comment">/*兼容谷歌和苹果*/</span></span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateY</span>(<span class="hljs-number">100px</span>);<span class="hljs-comment">/*兼容火狐*/</span></span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateY</span>(<span class="hljs-number">100px</span>);<span class="hljs-comment">/*兼容IE*/</span></span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateY</span>(<span class="hljs-number">100px</span>);<span class="hljs-comment">/*兼容opera浏览器*/</span></span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateY</span>(<span class="hljs-number">100px</span>);<span class="hljs-comment">/*兼容W3C浏览器*/</span></span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS3 2D变换<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS3 2D动画<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        *&#123;<br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;</span><br><span class="css">            <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;</span><br>        &#125;<br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br>            /*<br>            2个参数：第一个参数为横向放缩比例，第二个参数为纵向放缩比例。<br>            1个参数；纵向和横向放缩比例均为参数值。<br>            */<br><span class="css">            <span class="hljs-comment">/*-webkit-transform: scale(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: scale(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: scale(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: scale(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: scale(2);*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: scaleX(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: scaleX(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: scaleX(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: scaleX(2);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: scaleX(2);*/</span></span><br>            <br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">2</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">2</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">2</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">2</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scaleY</span>(<span class="hljs-number">2</span>);</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS3 2D动画<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        *&#123;<br><span class="css">            <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;</span><br>        &#125;<br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br><br><span class="css">            <span class="hljs-comment">/*顺时针旋转*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: rotate(10deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: rotate(10deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: rotate(10deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: rotate(10deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: rotate(10deg);*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*rotate()取值范围-360deg ~ 360deg*/</span></span><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(-<span class="hljs-number">10deg</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(-<span class="hljs-number">10deg</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(-<span class="hljs-number">10deg</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(-<span class="hljs-number">10deg</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(-<span class="hljs-number">10deg</span>);</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS3 2D转换<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        *&#123;<br><span class="css">            <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;</span><br>        &#125;<br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br><br><span class="css">            <span class="hljs-comment">/*两个参数，前横后纵*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: skew(20deg,20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: skew(20deg,20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: skew(20deg,20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: skew(20deg,20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: skew(20deg,20deg);*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*一个参数，仅仅是横向偏移*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: skew(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: skew(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: skew(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: skew(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: skew(20deg);*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*纵向扭曲*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: skewY(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: skewY(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: skewY(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: skewY(20deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: skewY(20deg);*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*纵向扭曲*/</span></span><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">skewX</span>(<span class="hljs-number">20deg</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">skewX</span>(<span class="hljs-number">20deg</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">skewX</span>(<span class="hljs-number">20deg</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">skewX</span>(<span class="hljs-number">20deg</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">skewX</span>(<span class="hljs-number">20deg</span>);</span><br>        &#125;<br>        <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h4 id="matrix-a-b-c-d-e-f-方法"><a href="#matrix-a-b-c-d-e-f-方法" class="headerlink" title="matrix(a,b,c,d,e,f)方法"></a>matrix(a,b,c,d,e,f)方法</h4><p>matrix()方法将所有2D转换方法组合在一起。</p>
<p>matrix()方法需要六个参数，包含数学函数，允许：旋转、缩放、移动以及倾斜元素。</p>
<p>定义2D变形转换，使用了六个值得矩阵，表示如下：</p>
<p>a    c    e</p>
<p>b    d    f</p>
<p>0    0    1</p>
<ul>
<li><p>matrix用一个3行3列的矩阵表示。</p>
<p>a和d：表示缩放，如果没有缩放，值为1</p>
<p>b和c：表示扭曲，如果没有扭曲，值为0</p>
<p>e和f：表示位移，如果没有位移，值为0</p>
</li>
<li><p>如果旋转角度为θ，它影响到a\b\c\d的值：</p>
<p>a = cosθ</p>
<p>b = sinθ</p>
<p>c = -sinθ</p>
<p>d = cosθ</p>
</li>
<li><p>如果扭曲skew(θ<del>1</del>,θ<del>2</del>)，会影响到b和c的值：</p>
<p>b = tanθ<del>1</del> </p>
<p>c = tanθ<del>2</del></p>
</li>
<li><p>每次旋转和扭曲都会产生一个新的矩阵，最终形成的多个矩阵要做乘法运算。</p>
</li>
<li><p>如果对一个元素同时有旋转、扭曲、缩放和位移，这时需要用到多个矩阵相乘，<strong>但是要优先考虑旋转和缩放！！！！！</strong></p>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>matrix()方法<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-comment">/*需求：将div右移100px，下移200px，旋转30deg，x轴缩放1.5倍，y轴缩放2倍。*/</span></span><br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">150px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: red;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br><span class="css">            <span class="hljs-attribute">color</span>: white;</span><br><span class="css">            <span class="hljs-comment">/*!*方法一：*!*/</span></span><br><span class="css">            <span class="hljs-comment">/*-webkit-transform: translate(100px,200px) scale(1.5,2.0) rotate(30deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transform: translate(100px,200px) scale(1.5,2.0) rotate(30deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transform: translate(100px,200px) scale(1.5,2.0) rotate(30deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transform: translate(100px,200px) scale(1.5,2.0) rotate(30deg);*/</span></span><br><span class="css">            <span class="hljs-comment">/*transform: translate(100px,200px) scale(1.5,2.0) rotate(30deg);*/</span></span><br><br><span class="css">            <span class="hljs-comment">/*方法2：*/</span></span><br>            /*解法：<br><span class="css">            <span class="hljs-number">1</span>.缩放（<span class="hljs-number">1.5</span>，<span class="hljs-number">2.0</span>），形成一个矩阵<span class="hljs-selector-tag">a</span>。</span><br>            [1.5 0   0<br>            0   2   0<br>            0   0   1]<br><span class="css">            <span class="hljs-number">2</span>.旋转<span class="hljs-number">30deg</span>后，形成一个矩阵<span class="hljs-selector-tag">b</span>。</span><br>            [0.866   -0.5    0<br>            0.5     0.866   0<br>            0       0       1]<br><span class="css">            <span class="hljs-number">3</span>.上面两个矩阵相乘，做乘法运算<span class="hljs-selector-tag">a</span>*<span class="hljs-selector-tag">b</span>。</span><br>            [0.866   -0.5    0          [1.5    0    0          [1.299  -1      0<br>            0.5     0.866   0       *   0       2    0      =    0.75   1.732   0<br>            0       0       1]          0       0    1]          0      0       1]<br>            4.带入偏移即可<br>            [1.299  -1      100<br>            0.75    1.732   200<br>            0       0       1]<br>            */<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">matrix</span>(<span class="hljs-number">1.299</span>,<span class="hljs-number">0.75</span>,-<span class="hljs-number">1</span>,<span class="hljs-number">1.732</span>,<span class="hljs-number">100</span>,<span class="hljs-number">200</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">matrix</span>(<span class="hljs-number">1.299</span>,<span class="hljs-number">0.75</span>,-<span class="hljs-number">1</span>,<span class="hljs-number">1.732</span>,<span class="hljs-number">100</span>,<span class="hljs-number">200</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">matrix</span>(<span class="hljs-number">1.299</span>,<span class="hljs-number">0.75</span>,-<span class="hljs-number">1</span>,<span class="hljs-number">1.732</span>,<span class="hljs-number">100</span>,<span class="hljs-number">200</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">matrix</span>(<span class="hljs-number">1.299</span>,<span class="hljs-number">0.75</span>,-<span class="hljs-number">1</span>,<span class="hljs-number">1.732</span>,<span class="hljs-number">100</span>,<span class="hljs-number">200</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">matrix</span>(<span class="hljs-number">1.299</span>,<span class="hljs-number">0.75</span>,-<span class="hljs-number">1</span>,<span class="hljs-number">1.732</span>,<span class="hljs-number">100</span>,<span class="hljs-number">200</span>);</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><br>        matrix()函数<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h4 id="transform-origin属性：调整元素的基点"><a href="#transform-origin属性：调整元素的基点" class="headerlink" title="transform-origin属性：调整元素的基点"></a>transform-origin属性：调整元素的基点</h4><p>允许改变被转换元素的位置</p>
<p><strong>语法</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html">transform-origin: x-axis y-axis c-axis;<br></code></pre></td></tr></table></figure>

<p>属性值：</p>
<ul>
<li>x-axis：定义视图被置于X轴的何处。可能值：left/center/right/length/%</li>
<li>y-axis：定义视图被置于Y轴的何处。可能值：top/center/bottom/length/%</li>
<li>z-axis：定义视图被置于Z轴的何处。可能值：length</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>transform-origin<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        .container&#123;<br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">300px</span>;</span><br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">400px</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br><span class="css">            <span class="hljs-attribute">border</span>: <span class="hljs-number">3px</span> solid salmon;</span><br>        &#125;<br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            <span class="hljs-comment">/*默认旋转中心：(x/2,y/2)处/对角线交点*/</span></span><br><span class="css">            -webkit-<span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;</span><br><span class="css">            -moz-<span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;</span><br><span class="css">            -ms-<span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;</span><br><span class="css">            -o-<span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;</span><br><span class="css">            <span class="hljs-attribute">transform-origin</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;container&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="8-1-2-CSS3-3D变形"><a href="#8-1-2-CSS3-3D变形" class="headerlink" title="8.1.2 CSS3 3D变形"></a>8.1.2 CSS3 3D变形</h3><h4 id="perspective"><a href="#perspective" class="headerlink" title="perspective"></a>perspective</h4><ul>
<li><p>perspective属性</p>
<p>perspective属性定义3D元素视距的距离，以像素计。该属性允许您改变3D元素查看3D元素的视图。当为元素定义perspective属性时，其子元素会获得透视效果，而不是元素本身。</p>
<ul>
<li><p>注意：perspective属性只影响3D转换元素。</p>
</li>
<li><p>语法：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">perspective</span>: number|none;<br></code></pre></td></tr></table></figure>

<p>number：元素距离视图的距离，以像素计。</p>
<p>none：默认值，与0相同，不设置透视。</p>
</li>
<li><p>主流浏览器都不支持，谷歌要加-webkit，或在长度后带单位。</p>
</li>
</ul>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>perspective属性<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        .father&#123;<br><span class="css">            <span class="hljs-attribute">position</span>: relative;</span><br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br><span class="css">            <span class="hljs-attribute">border</span>: <span class="hljs-number">3px</span> solid <span class="hljs-number">#8080ff</span>;</span><br>        &#125;<br>        .son&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">50px</span>;</span><br><span class="css">            <span class="hljs-attribute">padding</span>: <span class="hljs-number">50px</span>;</span><br><span class="css">            <span class="hljs-attribute">position</span>: absolute;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#00ffff</span>;</span><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">45deg</span>);</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-class">.father</span><span class="hljs-selector-pseudo">:hover</span>&#123;</span><br><span class="css">            -webkit-<span class="hljs-attribute">perspective</span>: <span class="hljs-number">150px</span>;</span><br><span class="css">            -moz-<span class="hljs-attribute">perspective</span>: <span class="hljs-number">150px</span>;</span><br><span class="css">            -ms-<span class="hljs-attribute">perspective</span>: <span class="hljs-number">150px</span>;</span><br><span class="css">            <span class="hljs-attribute">perspective</span>: <span class="hljs-number">150px</span>;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;father&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;son&quot;</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h4 id="transform-style"><a href="#transform-style" class="headerlink" title="transform-style"></a>transform-style</h4><p>transform-style属性规定如何在3D空间中呈现被嵌套元素(子元素)。</p>
<ul>
<li><p>注意：该属性必须和transform属性一起使用。</p>
</li>
<li><p>语法：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">transform-style</span>: flat|preserve-<span class="hljs-number">3</span>d;<br></code></pre></td></tr></table></figure>

<p>flat：子元素将不保留其3D位置。</p>
<p>preserve-3d：子元素将保留其3D位置。</p>
</li>
</ul>
<h4 id="rotate方法"><a href="#rotate方法" class="headerlink" title="rotate方法"></a>rotate方法</h4><p>rotateX    rotateY    </p>
<p>rotateZ：3D空间旋转指定角度，沿着垂直于Z轴的方向顺时针旋转。</p>
<p>X、Y、Z轴的三维立体感！！！<br>X平行纸面，<br>Y平行直面。<br>Z垂直纸面。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>绘制立方体<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        .container&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">position</span>: relative;</span><br><span class="css">            -webkit-<span class="hljs-attribute">perspective</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">            -moz-<span class="hljs-attribute">perspective</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">            -ms-<span class="hljs-attribute">perspective</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">            <span class="hljs-attribute">perspective</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">            <span class="hljs-attribute">margin</span>: <span class="hljs-number">200px</span> auto;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-class">.box</span> <span class="hljs-selector-tag">div</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">position</span>: absolute;</span><br><span class="css">            <span class="hljs-attribute">border</span>: <span class="hljs-number">3px</span> solid <span class="hljs-number">#00ffff</span>;</span><br>        &#125;<br>        .front,.back&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">300px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-comment">/*background-color: #8080ff;*/</span></span><br>        &#125;<br>        .left,.right&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">            <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-comment">/*background-color: deeppink;*/</span></span><br>        &#125;<br>        .top,.bottom&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">300px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">top</span>: <span class="hljs-number">50px</span>;</span><br><span class="css">            <span class="hljs-comment">/*background-color: salmon;*/</span></span><br>        &#125;<br>        .front&#123;<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">0</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">0</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">0</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">0</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">0</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br>        &#125;<br>        .back&#123;<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">180deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">180deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">180deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">180deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">180deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">50px</span>);</span><br>        &#125;<br>        .left&#123;<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br>        &#125;<br>        .right&#123;<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateY</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">150px</span>);</span><br>        &#125;<br>        .top&#123;<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br>        &#125;<br>        .bottom&#123;<br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotateX</span>(-<span class="hljs-number">90deg</span>) <span class="hljs-built_in">translateZ</span>(<span class="hljs-number">100px</span>);</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;container&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;front&quot;</span>&gt;</span>1<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;back&quot;</span>&gt;</span>2<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;right&quot;</span>&gt;</span>3<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;left&quot;</span>&gt;</span>4<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;top&quot;</span>&gt;</span>5<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;bottom&quot;</span>&gt;</span>6<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="8-2-CSS3过渡"><a href="#8-2-CSS3过渡" class="headerlink" title="8.2 CSS3过渡"></a>8.2 CSS3过渡</h2><p>transition属性是个简写属性，用于设置四个过渡属性。</p>
<ul>
<li>transition-property：属性名（单个或者一个列表）/all</li>
<li>transition-duration：动画持续时间</li>
<li>transition-timing-function：动画函数</li>
<li>transition-delay：动画延时时间</li>
</ul>
<p>第一个、第二个属性是必不可少的。</p>
<p>注释：请始终设置transition-duration属性，否则为0，就不会产生过渡效果。</p>
<p>简洁用法：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs css">xxxxxxxxxx xxxxxxxxxx  <span class="hljs-attribute">transition</span>: property duration timing-function delay     	<br></code></pre></td></tr></table></figure>

<ul>
<li><p>可以使用的属性：</p>
<ul>
<li><p>颜色：color  background-color border-color outline-color</p>
</li>
<li><p>位置：background-position left right top bottom</p>
</li>
<li><p>长度：max-height max-width min-height min-width width height</p>
<p>border-width margin padding outline-width outline-offset font-size</p>
<p>line-height text-indent vertical-align border-spacing letter-spacing word-spacing border-spacing </p>
</li>
<li><p>数字：opacity visibility z-index font-weight zoom</p>
</li>
<li><p>组合：text-shadow transform box-shadow clip</p>
</li>
<li><p>其他：gradient </p>
</li>
<li><p>动画持续时间：一般以秒s/毫秒ms为单位</p>
</li>
</ul>
</li>
<li><p>动画函数：</p>
<ul>
<li>linear：匀速</li>
<li>ease：变速（先加速再减速）</li>
<li>ease-in：变速（加速）</li>
<li>ease-out：变速（减速）</li>
<li>ease-in-out：变速（慢速开始,中间未知，慢速结束）</li>
<li>cubic-bezier(n,n,n,n)：自行设定变速，n的值在0~1之间</li>
</ul>
</li>
<li><p>动画延时时间：以秒或毫秒为单位。</p>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>transition过渡动画<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">800px</span>;</span><br><span class="css">            <span class="hljs-attribute">position</span>: relative;</span><br><span class="css">            <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid blueviolet;</span><br>        &#125;<br>        .demo&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: red;</span><br><span class="css">            <span class="hljs-attribute">position</span>: absolute;</span><br><span class="css">            <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">top</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-comment">/*-webkit-transition: all 3s ease 1s;*/</span></span><br><span class="css">            <span class="hljs-comment">/*-moz-transition: all 3s ease 1s;*/</span></span><br><span class="css">            <span class="hljs-comment">/*-ms-transition: all 3s ease 1s;*/</span></span><br><span class="css">            <span class="hljs-comment">/*-o-transition: all 3s ease 1s;*/</span></span><br><span class="css">            <span class="hljs-comment">/*transition: all 3s ease 1s;*/</span></span><br><span class="css">            -webkit-<span class="hljs-attribute">transition</span>: width <span class="hljs-number">3s</span> ease <span class="hljs-number">1s</span>,left <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">0.5s</span>;</span><br><span class="css">            -moz-<span class="hljs-attribute">transition</span>: width <span class="hljs-number">3s</span> ease <span class="hljs-number">1s</span>,left <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">0.5s</span>;</span><br><span class="css">            -ms-<span class="hljs-attribute">transition</span>: width <span class="hljs-number">3s</span> ease <span class="hljs-number">1s</span>,left <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">0.5s</span>;</span><br><span class="css">            -o-<span class="hljs-attribute">transition</span>: width <span class="hljs-number">3s</span> ease <span class="hljs-number">1s</span>,left <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">0.5s</span>;</span><br><span class="css">            <span class="hljs-attribute">transition</span>: width <span class="hljs-number">3s</span> ease <span class="hljs-number">1s</span>,left <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">0.5s</span>;</span><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">45deg</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">45deg</span>);</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-class">.box</span><span class="hljs-selector-pseudo">:hover</span> <span class="hljs-selector-class">.demo</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">left</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">300px</span>;</span><br><span class="css">            -webkit-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            -moz-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            -ms-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            -o-<span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br><span class="css">            <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">rotate</span>(<span class="hljs-number">30deg</span>);</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;demo&quot;</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="8-3-CSS3动画"><a href="#8-3-CSS3动画" class="headerlink" title="8.3 CSS3动画"></a>8.3 CSS3动画</h2><h3 id="8-3-1-keyframes"><a href="#8-3-1-keyframes" class="headerlink" title="8.3.1 @keyframes"></a>8.3.1 @keyframes</h3><p>通过@keyframes规则，可以创建动画，设置关键帧。</p>
<p>创建动画的原理：将一套CSS样式逐渐变化为另一套样式。</p>
<p>在动画过程中，可以多次改变这套样式。</p>
<p>以百分比来规定改变发生时间，或通过关键词”from”和”to”，等价于0%和100%。</p>
<p>0%是动画开始时间，100%动画的结束时间。</p>
<p>为了获得最佳的浏览器支持，应该始终定义0%和100%选择器。</p>
<p>注意：请使用动画属性来控制动画的外观，同时将动画与选择器绑定。</p>
<p>关键帧越多，动画越平滑。</p>
<p>步骤：</p>
<ul>
<li><p>设置关键帧</p>
<ul>
<li><p>只有两个关键帧</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-keyword">@keyframe</span> 动画名&#123;<br>	<span class="hljs-number">0%</span>: &#123;初始样式表&#125;;<br>	<span class="hljs-number">100%</span>: &#123;结尾样式表&#125;;<br>&#125;<br></code></pre></td></tr></table></figure>

<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-keyword">@keyframe</span> 动画名&#123;<br>	<span class="hljs-selector-tag">from</span>: &#123;初始样式表&#125;;<br>	<span class="hljs-selector-tag">to</span>: &#123;结尾样式表&#125;;<br>&#125;<br></code></pre></td></tr></table></figure>
</li>
<li><p>多个关键帧</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-keyword">@keyframe</span> 动画名&#123;<br>	<span class="hljs-number">0%</span>: &#123;初始样式表&#125;;<br>	百分比: &#123;对应样式表&#125;;<br>	<span class="hljs-number">100%</span>: &#123;结尾样式表&#125;;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>注意：这里的百分比一般是升序值，可以是0%~100%之间的任意值，也可以是倒序。</p>
</li>
</ul>
</li>
<li><p>实施动画</p>
<ul>
<li><p>常规用法</p>
<p>animation-name：规定需要绑定到选择器的keyframe名称。</p>
<p>animation-duration：规定完成动画所花费的时间，以秒/毫秒计。</p>
<p>animation-timing-function：规定动画的速度曲线。</p>
<ul>
<li>linear：匀速（默认值）</li>
<li>ease：变速（先加速再减速）</li>
<li>ease-in：变速（加速）</li>
<li>ease-out：变速（减速）</li>
<li>ease-in-out：变速（慢速开始,中间未知，慢速结束）</li>
<li>cubic-bezier(n,n,n,n)：自行设定变速，n的值在0~1之间</li>
</ul>
<p>animation-delay：规定动画开始之前的延迟。</p>
<p>animation-iteration-count：规定动画应该循环播放的次数。</p>
<ul>
<li>number：按设定次数循环</li>
<li>infinite：无限循环</li>
</ul>
<p>animation-direction：规定是否应该轮流反向播放动画。（默认为1次）</p>
<ul>
<li>normal：不反向</li>
<li>alternate：反向</li>
</ul>
<p>animation-play-state：动画是否播放或停止播放</p>
<ul>
<li>paused：停止播放</li>
<li>running：播放（默认）</li>
</ul>
</li>
<li><p>简洁用法</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-attribute">animation</span>: name,duration,timing-function,delay,iteration-count,direction;<br><span class="hljs-attribute">animation-play-state</span>: ;<br></code></pre></td></tr></table></figure>

</li>
</ul>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>关键帧动画<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>        .box&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">800px</span>;</span><br><span class="css">            <span class="hljs-attribute">position</span>: relative;</span><br>        &#125;<br>        .demo&#123;<br><span class="css">            <span class="hljs-attribute">width</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">height</span>: <span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">border</span>: <span class="hljs-number">#8080ff</span> <span class="hljs-number">1px</span> solid;</span><br><span class="css">            -webkit-<span class="hljs-attribute">border-radius</span>: <span class="hljs-number">50%</span>;</span><br><span class="css">            -moz-<span class="hljs-attribute">border-radius</span>: <span class="hljs-number">50%</span>;</span><br><span class="css">            <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">50%</span>;</span><br><span class="css">            <span class="hljs-attribute">position</span>: absolute;</span><br><span class="css">            -webkit-<span class="hljs-attribute">animation</span>: move <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">1s</span> infinite alternate;</span><br><span class="css">            -o-<span class="hljs-attribute">animation</span>: move <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">1s</span> infinite alternate;</span><br><span class="css">            <span class="hljs-attribute">animation</span>: move <span class="hljs-number">1s</span> ease-in-out <span class="hljs-number">1s</span> infinite alternate;</span><br>        &#125;<br><br><span class="css">        <span class="hljs-comment">/*定义关键帧*/</span></span><br><span class="css">        <span class="hljs-keyword">@keyframes</span> move &#123;</span><br>            0%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br>            &#125;<br>            30%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br>            &#125;<br>            75%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">400px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: blueviolet;</span><br>            &#125;<br>            100%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#87faf8</span>;</span><br>            &#125;<br>        &#125;<br><span class="css">        <span class="hljs-keyword">@-webkit-keyframes</span> move &#123;</span><br>            0%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br>            &#125;<br>            30%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br>            &#125;<br>            75%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">400px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: blueviolet;</span><br>            &#125;<br>            100%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#87faf8</span>;</span><br>            &#125;<br>        &#125;<br><span class="css">        <span class="hljs-keyword">@-moz-keyframes</span> move &#123;</span><br>            0%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br>            &#125;<br>            30%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br>            &#125;<br>            75%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">400px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: blueviolet;</span><br>            &#125;<br>            100%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#87faf8</span>;</span><br>            &#125;<br>        &#125;<br><span class="css">        <span class="hljs-keyword">@-o-keyframes</span> move &#123;</span><br>            0%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br>            &#125;<br>            30%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">220px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br>            &#125;<br>            75%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">400px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: blueviolet;</span><br>            &#125;<br>            100%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#87faf8</span>;</span><br>            &#125;<br>        &#125;<br><span class="css">        <span class="hljs-keyword">@-ms-keyframes</span> move &#123;</span><br>            0%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">100px</span>;</span><br>            &#125;<br>            30%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">200px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br>            &#125;<br>            75%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">400px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: blueviolet;</span><br>            &#125;<br>            100%&#123;<br><span class="css">                <span class="hljs-attribute">left</span>: <span class="hljs-number">500px</span>;</span><br><span class="css">                <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#87faf8</span>;</span><br>            &#125;<br>        &#125;<br><span class="css">        <span class="hljs-selector-class">.running</span><span class="hljs-selector-pseudo">:hover</span>+<span class="hljs-selector-class">.box</span> <span class="hljs-selector-class">.demo</span>&#123;</span><br><span class="css">            -webkit-<span class="hljs-attribute">animation-play-state</span>: running;</span><br><span class="css">            -moz-<span class="hljs-attribute">animation-play-state</span>: running;</span><br><span class="css">            -o-<span class="hljs-attribute">animation-play-state</span>: running;</span><br><span class="css">            <span class="hljs-attribute">animation-play-state</span>: running;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-class">.stop</span><span class="hljs-selector-pseudo">:hover</span>+<span class="hljs-selector-class">.box</span> <span class="hljs-selector-class">.demo</span>&#123;</span><br><span class="css">            -webkit-<span class="hljs-attribute">animation-play-state</span>: paused;</span><br><span class="css">            -moz-<span class="hljs-attribute">animation-play-state</span>: paused;</span><br><span class="css">            -o-<span class="hljs-attribute">animation-play-state</span>: paused;</span><br><span class="css">            <span class="hljs-attribute">animation-play-state</span>: paused;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;running&quot;</span>&gt;</span>running<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;stop&quot;</span>&gt;</span>stop<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;demo&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>


            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/CSS/">CSS</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2021/05/10/%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A013/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">PhotoShop基础</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/05/05/%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A012/">
                        <span class="hidden-mobile">CSS属性-动画</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->

  <div class="col-lg-7 mx-auto nopadding-x-md">
    <div class="container custom post-custom mx-auto">
      <img src="https://octodex.github.com/images/jetpacktocat.png" srcset="/img/loading.gif" class="rounded mx-auto d-block mt-5" style="width:150px; height:150px;">
    </div>
  </div>


    

    
      <a id="scroll-top-button" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  
  <!-- 备案信息 -->
  <div class="beian">
    <span>
      <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
        京ICP证123456号
      </a>
    </span>
    
      
        <span>
          <a
            href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12345678"
            rel="nofollow noopener"
            class="beian-police"
            target="_blank"
          >
            
              <span style="visibility: hidden; width: 0">|</span>
              <img src="/img/police_beian.png" srcset="/img/loading.gif" alt="police-icon"/>
            
            <span>京公网安备12345678号</span>
          </a>
        </span>
      
    
  </div>


  
</footer>

<!-- SCRIPTS -->

  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  



  <script  src="https://cdn.jsdelivr.net/npm/tocbot@4.12.0/dist/tocbot.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js" ></script>



  <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    (function () {
      var path = "/local-search.xml";
      $('#local-search-input').on('click', function() {
        searchFunc(path, 'local-search-input', 'local-search-result');
      });
      $('#modalSearch').on('shown.bs.modal', function() {
        $('#local-search-input').focus();
      });
    })()
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>



<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body>
</html>
